/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.model.disc.analysismodel;

import br.ufmg.dees.insane.materialMedia.material.Material;
import br.ufmg.dees.insane.model.disc.element.FrameElement;
import br.ufmg.dees.insane.model.disc.element.ParametricElement;
import br.ufmg.dees.insane.util.IMatrix;
import br.ufmg.dees.insane.util.IVector;

/**
*A class representing an plane stress analysis model.
*
*@author Fonseca, Flavio & Brugiolo, Marco & Lucas, Marcelo
*@version 1.0
*@since jdk1.4.1
*@see model.discrete.element.ParametricElement
*/

public class PlaneStressAnalysisM extends PlaneAnalysisM
{
	
	private static final long serialVersionUID = 1L;

	/** Constructs a PlaneStressAnalysisM analysis model, sets its type to PlaneStressAnalysisM.*/
	public PlaneStressAnalysisM() 
	{
		this.setType("PlaneStressAnalysisM");
	}
	
//********************************************************************************
	
	/** Mounts the matrix of the material properties for Plane Stress.
	*@param a The material properties.
	*@return matrix D related to plane stress.
	*/
	public IMatrix mountDMatrix(double[][] a) 
	{
		IMatrix d = new IMatrix(3,3);
		d.setZero();
		
		double elast = a[0][0];
		double ni = a[2][0];
		double k = ((elast)/(1-(ni*ni)));
		
		d.setElement(0,0,(1*k));
		d.setElement(0,1,(ni*k));
		d.setElement(0,2,0);
		d.setElement(1,0,(ni*k));
		d.setElement(1,1,(1*k));
		d.setElement(1,2,0);
		d.setElement(2,0,0);
		d.setElement(2,1,0);
		d.setElement(2,2,(((1-ni)/2)*k));
		
			return(d);
	}
	
//********************************************************************************

	/** Return the number of active stresses according to this Analysis model type.*/	
	public int getNumberOfActiveStress()
	{
		return 3;
	}
	
//********************************************************************************

	/** Return the number of active strains according to this Analysis model type.*/
	public int getNumberOfActiveStrains()
	{
		return 3;
	}
	
//********************************************************************************	
	
	/** Return the non zero stresses that perform in one point. 
	*@param a The IVector containing stresses of the point.
	*@param b The Material that will be used to obtain material properties.
	*@return stressVector The IVector according this Plane Stress Analysis Model.
	*/
	public IVector getStressVector(IVector a, Material b)
	{
			return a;
	}
	
//********************************************************************************

	/** Return the non zero strains that perform in one point. 
	*@param a The IVector containing strains of the point.
	*@param b The Material that will be used to obtain material properties.
	*@return strainVector The IVector according this Plane Stress Analysis Model.
	*/
	public IVector getStrainVector(IVector a, Material b)
	{
		IVector strainVector = new IVector(4);
		double[][] matProp = (b.getPs()).toDoubleArray();
		
		strainVector.setElement(0, a.getElement(0)); 
		strainVector.setElement(1, a.getElement(1));
//verificar se esta linha de codigo abaixo esta correta
		strainVector.setElement(2, ((-1)*(matProp[0][1])*(a.getElement(0)+a.getElement(1))));
		strainVector.setElement(3, a.getElement(2));
			
		return strainVector;
	}
	
//********************************************************************************
	
	/** Return the String representing the non zero stresses of this Plane Stress Analysis Model.
	*@return The string containing the label of non zero stresses of this Plane Stress Analysis Model.
	*/
	public String getStressLabels()
	{
		return ("sigmaXX sigmaYY tauXY");
	}
	
//********************************************************************************
	
	/** Return the string representing the non zero strains of this Plane Stress Analysis Model.
	*@return The string containing the label of non zero strains of this Plane Stress Analysis Model.
	*/
	public String getStrainLabels()
	{
		return ("epsilonXX epsilonYY epsilonZZ gammaXY");
	}

//********************************************************************************
	
	/** Returns the type of the Shape adequate to this type of AnalysisModel.
	*@return The type of the Shape adequate to this type of AnalysisModel.
	*/
	public String getDefaultShapeType()
	{
		return null;
	}
	
//********************************************************************************
	
	/** Returns the nodal rotation matrix of the specified ParametricElement, accordingly to this AnalysisModel type.
	*@param elm The ParametricElement whose nodal rotation matrix is desired.
	*@return The nodal rotation matrix of the specified ParametricElement, accordingly to this AnalysisModel type.
	*/
	public IMatrix nodalRotationMatrix(ParametricElement elm)
	{
		return null;
	}
	
//********************************************************************************
	
	/** Returns the local stiffness matrix of the specified ParametricElement, accordingly to this AnalysisModel type.<br>
	*This matrix does not consider the possible liberations at the extremities of the ParametricElement.
	*@param elm The ParametricElement whose local stiffness matrix is desired.
	*@return The local stiffness matrix of the specified ParametricElement, accordingly to this AnalysisModel type.
	*/
	public IMatrix localStiffnessMatrix(ParametricElement elm)
	{
		return null;
	}
	
//********************************************************************************
	
	/** Returns the corrected local stiffness matrix of the specified ParametricElement, accordingly to this AnalysisModel type.
	*This matrix is the same matrix calculated in the localStiffnessMatrix() method, because there is no liberation at extremities in a truss.
	*@param elm The ParametricElement whose corrected local stiffness matrix is desired.
	*@return The corrected local stiffness matrix of the specified ParametricElement, accordingly to this AnalysisModel type.
	*/
	public IMatrix localCorrectedStiffnessMatrix(ParametricElement elm)
	{
		return null;
	}
	
//********************************************************************************
	
	/** Returns the transformation matrix of the specified ParametricElement, accordingly to this AnalysisModel type.
	*@param elm The ParametricElement whose transformation matrix is desired.
	*@return The transformation matrix of the specified ParametricElement, accordingly to this AnalysisModel type.
	*/
	public IMatrix transformationMatrix(ParametricElement elm)
	{
		return null;
	}
	
	
//********************************************************************************
	
	/** Returns the local equivalent nodal force vector of the specified ParametricElement, accordingly to this AnalysisModel type.
	*This vector does not consider the possible liberations at the extremities of the ParametricElement.
	*@param elm The ParametricElement whose local equivalent nodal force vector is desired.
	*@return The local equivalent nodal force vector of the specified ParametricElement, accordingly to this AnalysisModel type.
	*/
	public IVector localEquivalentForceVector(ParametricElement elm)
	{
		return null;
	}
	
//********************************************************************************
	
	/** Returns the corrected local equivalent nodal force vector of the specified ParametricElement, accordingly to this AnalysisModel type.
	*This vector is the same vector calculated in the localEquivalentForceVector() method, because there is no liberation at extremities in a truss.
	*@param elm The ParametricElement whose corrected local equivalent nodal force vector is desired.
	*@return The corrected local equivalent nodal force vector of the specified ParametricElement, accordingly to this AnalysisModel type.
	*/
	public IVector localCorrectedEquivalentForceVector(ParametricElement elm)
	{
		return null;
	}
	
	public IMatrix transformationMatrix(FrameElement elm) {
		return null;
	} 
	
//********************************************************************************

}
